package com.inno.subject.infra.basic.service.impl;

import com.github.pagehelper.Page;
import com.inno.subject.infra.basic.entity.PlannerSubjectRecords;
import com.inno.subject.infra.basic.mapper.PlannerSubjectRecordsDao;
import com.inno.subject.infra.basic.service.PlannerSubjectRecordsService;
import com.inno.subject.infra.entity.RankCountBO;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (PlannerSubjectRecords)表服务实现类
 *
 * @author makejava
 * @since 2024-11-16 20:57:06
 */
@Service
public class PlannerSubjectRecordsServiceImpl implements PlannerSubjectRecordsService {
    @Resource
    private PlannerSubjectRecordsDao plannerSubjectRecordsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public PlannerSubjectRecords queryById(Long id) {
        return this.plannerSubjectRecordsDao.queryById(id);
    }

    @Override
    public long count(PlannerSubjectRecords plannerSubjectRecords) {
        return this.plannerSubjectRecordsDao.count(plannerSubjectRecords);
    }


    /**
     * 新增数据
     *
     * @param plannerSubjectRecords 实例对象
     * @return 实例对象
     */
    @Override
    public PlannerSubjectRecords insert(PlannerSubjectRecords plannerSubjectRecords) {
        this.plannerSubjectRecordsDao.insert(plannerSubjectRecords);
        return plannerSubjectRecords;
    }

    /**
     * 修改数据
     *
     * @param plannerSubjectRecords 实例对象
     * @return 实例对象
     */
    @Override
    public PlannerSubjectRecords update(PlannerSubjectRecords plannerSubjectRecords) {
        this.plannerSubjectRecordsDao.update(plannerSubjectRecords);
        return this.queryById(plannerSubjectRecords.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.plannerSubjectRecordsDao.deleteById(id) > 0;
    }

    @Override
    public void insertBatch(List<PlannerSubjectRecords> recordsList) {
        this.plannerSubjectRecordsDao.insertBatch(recordsList);
    }

    @Override
    public List<RankCountBO> queryTotalCountGroupUserId() {
        return this.plannerSubjectRecordsDao.queryTotalCountGroupUserId();
    }

    @Override
    public List<PlannerSubjectRecords> queryByUserIdAndSubjectIdList(Long currentUser, List<Long> subjectIdList) {
        return this.plannerSubjectRecordsDao.queryByUserIdAndSubjectIdList(currentUser,subjectIdList);
    }

    @Override
    public Page<PlannerSubjectRecords> queryPage(PlannerSubjectRecords plannerSubjectRecords) {
        return this.plannerSubjectRecordsDao.queryPage(plannerSubjectRecords);
    }

    @Override
    public Page<PlannerSubjectRecords> queryErrorSubjectId(PlannerSubjectRecords records) {
        return this.plannerSubjectRecordsDao.queryErrorSubjectId(records);
    }

    @Override
    public List<Long> queryCountGroupSubjectId(Long currentUser) {
        return this.plannerSubjectRecordsDao.queryCountGroupSubjectId(currentUser);
    }

    @Override
    public void deleteBatch(List<Long> needDeleteList) {
        this.plannerSubjectRecordsDao.deleteBatch(needDeleteList);
    }
}
